package socket;

import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author mjy
 * @date 2021/12/23
 * @description
 */
public class StuServerSocket {

    public static void main(String[] args) throws  Exception {
        ServerSocket serverSocket = new ServerSocket(5569);
        Socket accept = serverSocket.accept();
        byte[] data = new byte[1024];
        //读取客户端的数据
        InputStream in = accept.getInputStream();
        int length = in.read(data);
        String hc = new String(data, 0, length);
        System.out.println("读取到客户端发送来的数据：" + hc);
        //向客户端发送数据
        accept.getOutputStream().write("发送给客户端数据cs".getBytes());

    }
}
